#!/usr/bin/python
import sys, os
from t3sphinx import t3amConvert
from optparse import OptionParser

def which( bin ):
    """Trivial Unix 'which' emulation."""
    exec_paths = os.environ['PATH'].split(":")
    for path in exec_paths:
        if os.path.exists(path + "/" + bin):
            return True
    return False

if __name__=="__main__":
    parser = OptionParser()
    parser.add_option("-i","--amroot", dest="amroot", default="./" )
    parser.add_option("-o","--outputroot", dest="outputroot", default="./t3pyAM" )
    (options, args) = parser.parse_args()
    #Options to add: hmmsyms, hmmvar, hmmmean, hmmst, clevelarcs, hlevelarcs, hmmhmm, hmmpdf, hmmdur
    #Initialize the model
    sphinxModel = t3amConvert.sphinx2T3( modelroot=options.amroot, outputroot=options.outputroot )
    #Build it.
    sphinxModel.build_all( )     
